package cn.edu.sgu.www.mhxysy.controller.except;

import cn.edu.sgu.www.mhxysy.consts.CustomConstants;
import cn.edu.sgu.www.mhxysy.consts.MimeTypes;
import cn.edu.sgu.www.mhxysy.entity.except.JiadianSchema;
import cn.edu.sgu.www.mhxysy.restful.JsonResult;
import cn.edu.sgu.www.mhxysy.service.except.JiadianSchemaService;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Api(tags = "加点方案管理")
@ApiSupport(author = CustomConstants.AUTHOR)
@RestController
@RequestMapping(path = "/jiadian_schema", produces = MimeTypes.APPLICATION_JSON_CHARSET_UTF_8)
public class JiadianSchemaController {

    private final JiadianSchemaService jiadianSchemaService;

    @Autowired
    public JiadianSchemaController(JiadianSchemaService jiadianSchemaService) {
        this.jiadianSchemaService = jiadianSchemaService;
    }

    @ApiOperation("查询全部加点方案")
    @RequestMapping(value = "/selectAll", method = RequestMethod.GET)
    public JsonResult<List<JiadianSchema>> selectAll() {
        List<JiadianSchema> list = jiadianSchemaService.selectAll();

        return JsonResult.success(null, list);
    }

    @ApiOperation("查询角色的加点方案")
    @RequestMapping(value = "/selectByRoleId", method = RequestMethod.GET)
    public JsonResult<List<JiadianSchema>> selectByRoleId(
            @ApiParam(name = "roleId", value = "角色ID", required = false)
            @RequestParam(required = false) String roleId) {
        List<JiadianSchema> list = jiadianSchemaService.selectByRoleId(roleId);

        return JsonResult.success(null, list);
    }

    @ApiOperation("查询宠物的加点方案")
    @RequestMapping(value = "/selectByChongwuId", method = RequestMethod.GET)
    public JsonResult<List<JiadianSchema>> selectByChongwuId(
            @ApiParam(name = "chongwuId", value = "宠物ID", required = false)
            @RequestParam(required = false) String chongwuId) {
        List<JiadianSchema> list = jiadianSchemaService.selectByChongwuId(chongwuId);

        return JsonResult.success(null, list);
    }

}